package com.lvmama.rhino.enums;

import com.lvmama.rhino.utils.Constants;
import com.lvmama.rhino.utils.RhinoConstant;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public enum NPSPushEmailListEnum {
    TICKET("景乐", "zhouxiongfei@lvmama.com,haowenbin@lvmama.com,ehounan@lvmama.com,chenxiaogang@lvmama.com,wuyu@lvmama.com,chenzhipeng@lvmama.com", Arrays.asList(11, 12, 13),0),
    HOTEL("景酒", "luobiao@lvmama.com,chenlimin@lvmama.com,chencuiwen@lvmam.com,zengchun@lvmama.com,liruili@lvmama.com,xuyingying@lvmama.com,zhangyisheng@lvmama.com,tanshijun@lvmama.com,wumeng@lvmama.com", Collections.singletonList(181),0),
    GROUP("跟团游","wuxuefeng@lvmama.com,heyu@lvmama.com,xiamengen@lvmama.com,shishenghao@lvmama.com,wangailing@lvmama.com,mengshuchao@lvmama.com,sunan@lvmama.com,xiaomaohang@lvmama.com,xieshaobo@lvmama.com", Collections.singletonList(15),0),
    TRAFFIC("机酒大交通","liwanwan@lvmama.com,maweiwei@lvmama.com,guanjunyuan@lvmama.com,louming@lvmama.com,fengyinmin@lvmama.com,tianqing@lvmama.com,shenwenbin@lvmama.com",Collections.singletonList(182),0),
    OUTSIDE("出境","yingjianfeng@lvmama.com,guowenjing@lvmama.com,xufei@lvmama.com,cjqa@lvmama.com,wangyanjun@lvmama.com,zhaoxian@lvmama.com,yaojiping@lvmama.com,gusui@lvmama.com",Arrays.asList(2, 15, 18),0),
    ALL("全部","fangtengfei@lvmama.com,zhouxiaoying@lvmama.com,hebicheng@lvmama.com,zhouke@lvmama.com,yelin@lvmama.com,caoyong@lvmama.com",null,0),

    TICKET_TEST("景乐-测试", "yuanye@lvmama.com,caoyong@lvmama.com", Arrays.asList(11, 12, 13),1),
    HOTEL_TEST("景酒-测试", "yuanye@lvmama.com,caoyong@lvmama.com", Collections.singletonList(181),1),
    GROUP_TEST("跟团游-测试","yuanye@lvmama.com,caoyong@lvmama.com", Collections.singletonList(15),1),
    TRAFFIC_TEST("机酒大交通-测试","yuanye@lvmama.com,caoyong@lvmama.com",Collections.singletonList(182),1),
    OUTSIDE_TEST("出境-测试","yuanye@lvmama.com,caoyong@lvmama.com",Arrays.asList(2, 15, 18),1),
    ALL_TEST("全部-测试","yuanye@lvmama.com,caoyong@lvmama.com",null,1);

    private String name;
    private String value;
    private List<Integer> categoryIds;
    /**
     * 0生产 1测试
     */
    private Integer type;

    NPSPushEmailListEnum(String name, String value, List<Integer> categoryIds, Integer type) {
        this.name = name;
        this.value = value;
        this.categoryIds = categoryIds;
        this.type = type;
    }

    /**
     * 根据环境，获取所有的枚举
     * @return
     */
    public static NPSPushEmailListEnum[] getAllEnum(){
        RhinoConstant rhinoConstant = RhinoConstant.getInstance();
        List<NPSPushEmailListEnum> prd = new ArrayList<>();
        List<NPSPushEmailListEnum> test = new ArrayList<>();
        String env = rhinoConstant.getValue("rhino.env");
        for (NPSPushEmailListEnum en : NPSPushEmailListEnum.values()){
            if(en.getType().equals(0)){
                prd.add(en);
            }else if(en.getType().equals(1)){
                test.add(en);
            }
        }
        if(Constants.EVN_PRD.equals(env)){
            NPSPushEmailListEnum[] prdArray = new NPSPushEmailListEnum[prd.size()];
            return prd.toArray(prdArray);
        }else {
            NPSPushEmailListEnum[] testArray = new NPSPushEmailListEnum[test.size()];
            return test.toArray(testArray);
        }
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    public List<Integer> getCategoryIds() {
        return categoryIds;
    }

    public Integer getType() {
        return type;
    }
}
